package leetcode.code1003;

import leetcode.IDebug;
import leetcode.helper.H;

public class Solution implements IDebug {

	public boolean isValid(String s) {
		char[] stack = new char[s.length()];
		int p = 0;
		for (int i = 0; i < stack.length; i++) {
			char cur = s.charAt(i);
			if (cur == 'a') {
				stack[p++] = cur;
			} else if (cur == 'b') {
				if (p - 1 < 0 || stack[p - 1] != 'a') {
					return false;
				}
				stack[p++] = cur;
			} else {
				if (p - 2 < 0 || stack[p - 1] != 'b') {
					return false;
				}
				p -= 2;
			}
		}
		return p == 0;
	}

	@Override
	public void debug4() {
		H.compare(true, this.isValid("aabcbc"));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();
		String sql ="SELECT "
				+ " t1.id id1,"
				+ " t2.*"
				+ " FROM"
				+ " DSM_MP_TABLE_COL t1,"
				+ " DSM_MP_TABLE_COL_INFO t2"
				+ " WHERE"
				+ " t1.ID_COL = t2.ID"
				+ " AND t1.ID_TABLE =(SELECT id FROM DSM_MP_TABLE WHERE table_name like #{table_name} )";
		System.out.println(sql);
	}

}
